package com.magiccompass.alipay.barcode.entity;

import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

import com.magiccompass.alipay.barcode.model.AlipayBarcodeBaseResponse;

@Entity
@Table(name = "TD_ALIPAY_BARCODE_CANCEL_RESPONSE")
@DynamicUpdate(value= true)
public class AlipayBarcodeCancelResponse extends AlipayBarcodeBaseResponse {
	@Id
	@Column(name = "ID")
	@GeneratedValue
	private Integer id;
	
	@OneToOne(cascade=CascadeType.MERGE,fetch= FetchType.EAGER)
	@JoinColumn(name="merchant_transaction_id",unique=true)
	private MerchantTransaction merchantTransaction;
	
	@OneToOne(cascade=CascadeType.MERGE,fetch= FetchType.EAGER)
	@JoinColumn(name="alipay_barcode_cancel_request_id",unique=true)
	private AlipayBarcodeCancelRequest alipayBarcodeCancelRequest;
	
	@Column(name = "is_success",length=1, nullable=false)
	private String isSuccess;
	
	@Column(name = "sign_type",length=10, nullable=false)
	private String signType;
	
	@Column(name = "sign",length=1024, nullable=false)
	private String sign;
	
	@Column(name = "result_code",length=32, nullable=false)
	private String resultCode = "-1";  // -1 means self define result code; because this column is nullable=false, but ALIPAY doesn't set this column when is_success=F.
	
	@Column(name = "error",length=48)
	private String error;
	
	@Column(name = "partner_trans_id",length=64, nullable=false)
	private String partnerTransId;
	
	@Column(name = "alipay_trans_id",length=64, nullable=true)
	private String alipayTransId;
	
	@Column(name = "alipay_cancel_time", nullable=true)
	private Timestamp alipayCancelTime;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public MerchantTransaction getMerchantTransaction() {
		return merchantTransaction;
	}

	public void setMerchantTransaction(MerchantTransaction merchantTransaction) {
		this.merchantTransaction = merchantTransaction;
	}

	public String getIsSuccess() {
		return isSuccess;
	}

	public void setIsSuccess(String isSuccess) {
		this.isSuccess = isSuccess;
	}

	public String getSignType() {
		return signType;
	}

	public void setSignType(String signType) {
		this.signType = signType;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getResultCode() {
		return resultCode;
	}

	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public String getPartnerTransId() {
		return partnerTransId;
	}

	public void setPartnerTransId(String partnerTransId) {
		this.partnerTransId = partnerTransId;
	}

	public String getAlipayTransId() {
		return alipayTransId;
	}

	public void setAlipayTransId(String alipayTransId) {
		this.alipayTransId = alipayTransId;
	}

	public Timestamp getAlipayCancelTime() {
		return alipayCancelTime;
	}

	public void setAlipayCancelTime(Timestamp alipayCancelTime) {
		this.alipayCancelTime = alipayCancelTime;
	}

	public AlipayBarcodeCancelRequest getAlipayBarcodeCancelRequest() {
		return alipayBarcodeCancelRequest;
	}

	public void setAlipayBarcodeCancelRequest(AlipayBarcodeCancelRequest alipayBarcodeCancelRequest) {
		this.alipayBarcodeCancelRequest = alipayBarcodeCancelRequest;
	}
	
}